layui.use(['jquery','form'],function () {
    let form = layui.form;
    let $ = layui.$;
    let user = JSON.parse(localStorage.getItem('user'));
    //为隐藏域赋值
    $('#userId').val(user.data.userId);
    getCourseClassSelect();
    //关闭功能
    $('#close').click(function () {
        var layer = parent.layer;
        layer.close(layer.index);
    });
    //获取所有课程分类
    function getCourseClassSelect() {
        $.ajax({
            url : '/courseClass/getAllJsCourseClassSelect',
            dataType: 'json',
            success: function (data) {
                var allCourseClass = data.data;
                //进行layui下拉框赋值
                for (var i = 0; i < allCourseClass.length; i++) {
                    $('#courseClass').append('<option value="'+allCourseClass[i].id+'">'+allCourseClass[i].name+'</option>');
                }
                form.render();
            }
        });
    }

    form.on('submit(sub)',function (obj) {
        $.ajax({
            url: '/course/getSelfCoursesCheck',
            data: obj.field,
            dataType: 'json',
            success: function (data) {
                parent.selfCourseTableRender(data.data);
                var layer = parent.layer;
                layer.close(layer.index)
            }
        });
        return false;
    });
})